package com.zky.consumer;

import com.zky.domain.po.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@Slf4j
public class ConsumerTest {
    @RabbitListener(bindings = @QueueBinding(
        value = @Queue(name = "test_queue",durable = "true"),
        exchange = @Exchange(name = "test_exchange",type = ExchangeTypes.TOPIC),
        key = {"zky.#"}
    ))
    public void test(Student message){
        System.out.println("message: "+message);
    }
    @PostConstruct
    public void init(){
        log.debug("创建consumer");
    }
}
